<?php
/**
 * Created by a front-end programmer.
 * User: Xwen
 * Date: 2018/2/24
 * Time: 18:06
 * Mail:lauwencn@gmail.com
 */
class UserModel extends Model{
    public $table = 'authority_user';
    public function __construct($table = NULL)
    {
        $table = $this->table;
        parent::__construct($table);
    }

    public function validate($username, $password){
        //用户名不能为空
        if(!$username) return false;
        $userInfo = $this->where('username="'.$username.'"')->find();
        //用户名不存在
        if(!$userInfo) return false;
        //密码错误
        if($userInfo['password'] != md5($password)) return false;
        return $userInfo;
    }
}